package cn.catsdad.service.impl;

import cn.catsdad.base.service.impl.BaseServiceImpl;
import cn.catsdad.dto.PositionUserDTO;
import cn.catsdad.repository.PositionUserRepository;
import cn.catsdad.service.api.PositionUserService;
import cn.catsdad.util.StringUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * 岗位用户service实现
 *
 * @author xuyonglong
 * @version V1.0 2023/4/13
 */
@Service
public class PositionUserServiceImpl extends BaseServiceImpl<PositionUserDTO, Long, PositionUserRepository>
        implements PositionUserService {

    @Override
    @Transactional
    public void deleteByUserIdIn(Collection<Long> userIds) {
        if (userIds != null) {
            repository.deleteByUserIdIn(userIds);
        }
    }

    @Override
    public List<PositionUserDTO> queryByUserIds(Collection<Long> userIds) {
        List<PositionUserDTO> result = new ArrayList<>();
        if (StringUtil.isNotEmpty(userIds)) {
            result = repository.findByUserIdIn(userIds);
        }
        return result;
    }

}
